home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-11 | 12.5 KB | 542 lines | [TEXT/MPS ] |
- ;
- ; File: SoundComponents.a
- ;
- ; Copyright: © 1984-1994 by Apple Computer, Inc.
- ; All rights reserved.
- ;
- ; Version: Universal Interfaces 2.0a3 ETO #16, MPW prerelease. Friday, November 11, 1994.
- ;
- ; Bugs?: If you find a problem with this file, send the file and version
- ; information (from above) and the problem description to:
- ;
- ; Internet: apple.bugs@applelink.apple.com
- ; AppleLink: APPLE.BUGS
- ;
- ;
-
- IF &TYPE('__SOUNDCOMPONENTS__') = 'UNDEFINED' THEN
- __SOUNDCOMPONENTS__ SET 1
-
-
- IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
- include 'Types.a'
- ENDIF
- ; include 'ConditionalMacros.a' ;
-
- IF &TYPE('__COMPONENTS__') = 'UNDEFINED' THEN
- include 'Components.a'
- ENDIF
- ; include 'MixedMode.a' ;
-
- IF &TYPE('__SOUND__') = 'UNDEFINED' THEN
- include 'Sound.a'
- ENDIF
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; constants
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- ;sound component set/get info selectors
- siVolume EQU 'volu'
- siHardwareVolume EQU 'hvol'
- siSpeakerVolume EQU 'svol'
- siHeadphoneVolume EQU 'pvol'
- siHardwareVolumeSteps EQU 'hstp'
- siHeadphoneVolumeSteps EQU 'hdst'
- siHardwareMute EQU 'hmut'
- siSpeakerMute EQU 'smut'
- siHeadphoneMute EQU 'pmut'
- siRateMultiplier EQU 'rmul'
- siQuality EQU 'qual'
- ;format types
- kOffsetBinary EQU 'raw '
- kTwosComplement EQU 'twos'
- kMACE3Compression EQU 'MAC3'
- kMACE6Compression EQU 'MAC6'
-
- ;quality flags
- ;use interpolation in rate conversion
- kBestQuality EQU (1 << 0)
-
- ;useful bit masks
- kInputMask EQU $000000FF ;masks off input bits
- kOutputMask EQU $0000FF00 ;masks off output bits
- kOutputShift EQU 8 ;amount output bits are shifted
- kActionMask EQU $00FF0000 ;masks off action bits
- kSoundComponentBits EQU $00FFFFFF
-
- ;SoundComponentPlaySourceBuffer action flags
- kSourcePaused EQU (1 << 0)
- kPassThrough EQU (1 << 16)
- kNoSoundComponentChain EQU (1 << 17)
- ;flags for OpenMixerSoundComponent
- kNoMixing EQU (1 << 0) ;don't mix source
- kNoSampleRateConversion EQU (1 << 1) ;don't convert sample rate (i.e. 11 kHz -> 22 kHz)
- kNoSampleSizeConversion EQU (1 << 2) ;don't convert sample size (i.e. 16 -> 8)
- kNoSampleFormatConversion EQU (1 << 3) ;don't convert sample format (i.e. 'twos' -> 'raw ')
- kNoChannelConversion EQU (1 << 4) ;don't convert stereo/mono
- kNoDecompression EQU (1 << 5) ;don't decompress (i.e. 'MAC3' -> 'raw ')
- kNoVolumeConversion EQU (1 << 6) ;don't apply volume
- kNoRealtimeProcessing EQU (1 << 7) ;won't run at interrupt time
-
- ;Audio Component constants
- ;Values for whichChannel parameter
- audioAllChannels EQU 0 ;All channels (usually interpreted as both left and right)
- audioLeftChannel EQU 1 ;Left channel
- audioRightChannel EQU 2 ;Right channel
- ;Values for mute parameter
- audioUnmuted EQU 0 ;Device is unmuted
- audioMuted EQU 1 ;Device is muted
- ;Capabilities flags definitions
- audioDoesMono EQU (1 << 0) ;Device supports mono output
- audioDoesStereo EQU (1 << 1) ;Device supports stereo output
- audioDoesIndependentChannels EQU (1 << 2) ;Device supports independent software control of each channel
-
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; typedefs
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ;ShortFixed consists of an 8 bit, 2's complement integer part in the high byte,
- ;with an 8 bit fractional part in the low byte; its range is -128 to 127.99609375
- SoundComponentData RECORD 0
- flags ds.l 1
- format ds.l 1
- numChannels ds.w 1
- sampleSize ds.w 1
- sampleRate ds.l 1
- sampleCount ds.l 1
- buffer ds.l 1
- reserved ds.l 1
- sizeof EQU 28
- ENDR
-
- SoundParamBlock RECORD 0
- recordSize ds.l 1 ;size of this record in bytes
- desc ds SoundComponentData ;description of sound buffer
- rateMultiplier ds.l 1 ;rate multiplier to apply to sound
- leftVolume ds.w 1 ;volumes to apply to sound
- rightVolume ds.w 1
- quality ds.l 1 ;quality to apply to sound
- filter ds.l 1 ;filter to apply to sound
- moreRtn ds.l 1 ;routine to call to get more data
- completionRtn ds.l 1 ;routine to call when buffer is complete
- refCon ds.l 1 ;user refcon
- result ds.w 1 ;result
- sizeof EQU 62
- ENDR
-
- AudioInfo RECORD 0
- capabilitiesFlags ds.l 1 ;Describes device capabilities
- reserved ds.l 1 ;Reserved by Apple
- numVolumeSteps ds.w 1 ;Number of significant increments between min and max volume
- sizeof EQU 10
- ENDR
-
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; functions for sound components
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ;Sound Component dispatch selectors
-
- ;these calls cannot be delegated
- kSoundComponentInitOutputDeviceSelect EQU 1
- kSoundComponentSetSourceSelect EQU 2
- kSoundComponentGetSourceSelect EQU 3
- kSoundComponentGetSourceDataSelect EQU 4
- kSoundComponentSetOutputSelect EQU 5
- kDelegatedSoundComponentSelectors EQU $0100 ;first selector that can be delegated up the chain
- ;these calls can be delegated and have own range
- kSoundComponentAddSourceSelect EQU kDelegatedSoundComponentSelectors + 1
- kSoundComponentRemoveSourceSelect EQU kDelegatedSoundComponentSelectors + 2
- kSoundComponentGetInfoSelect EQU kDelegatedSoundComponentSelectors + 3
- kSoundComponentSetInfoSelect EQU kDelegatedSoundComponentSelectors + 4
- kSoundComponentStartSourceSelect EQU kDelegatedSoundComponentSelectors + 5
- kSoundComponentStopSourceSelect EQU kDelegatedSoundComponentSelectors + 6
- kSoundComponentPauseSourceSelect EQU kDelegatedSoundComponentSelectors + 7
- kSoundComponentPlaySourceBufferSelect EQU kDelegatedSoundComponentSelectors + 8
-
- ;Audio Component selectors
- kAudioGetVolumeSelect EQU 0
- kAudioSetVolumeSelect EQU 1
- kAudioGetMuteSelect EQU 2
- kAudioSetMuteSelect EQU 3
- kAudioSetToDefaultsSelect EQU 4
- kAudioGetInfoSelect EQU 5
- kAudioGetBassSelect EQU 6
- kAudioSetBassSelect EQU 7
- kAudioGetTrebleSelect EQU 8
- kAudioSetTrebleSelect EQU 9
- kAudioGetOutputDeviceSelect EQU 10
- kAudioMuteOnEventSelect EQU 129
-
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; Sound Manager 3.0 utilities
- IF GENERATING68K THEN
- Macro
- _OpenMixerSoundComponent
- dc.w $203C
- dc.w $0614
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT OpenMixerSoundComponent
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _CloseMixerSoundComponent
- dc.w $203C
- dc.w $0218
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT CloseMixerSoundComponent
- ENDIF
-
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; basic sound component functions
- IF GENERATING68K THEN
- Macro
- _SoundComponentInitOutputDevice
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentInitOutputDevice
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentSetSource
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentSetSource
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentGetSource
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentGetSource
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentGetSourceData
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentGetSourceData
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentSetOutput
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentSetOutput
- ENDIF
-
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; junction methods for the mixer, must be called at non-interrupt level
- IF GENERATING68K THEN
- Macro
- _SoundComponentAddSource
- dc.w $2F3C
- dc.w $0000
- dc.w $0101
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentAddSource
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentRemoveSource
- dc.w $2F3C
- dc.w $0000
- dc.w $0102
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentRemoveSource
- ENDIF
-
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; info methods
- IF GENERATING68K THEN
- Macro
- _SoundComponentGetInfo
- dc.w $2F3C
- dc.w $0002
- dc.w $0103
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentGetInfo
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentSetInfo
- dc.w $2F3C
- dc.w $0002
- dc.w $0104
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentSetInfo
- ENDIF
-
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; control methods
- IF GENERATING68K THEN
- Macro
- _SoundComponentStartSource
- dc.w $2F3C
- dc.w $0000
- dc.w $0105
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentStartSource
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentStopSource
- dc.w $2F3C
- dc.w $0000
- dc.w $0106
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentStopSource
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentPauseSource
- dc.w $2F3C
- dc.w $0000
- dc.w $0107
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentPauseSource
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SoundComponentPlaySourceBuffer
- dc.w $2F3C
- dc.w $0002
- dc.w $0108
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT SoundComponentPlaySourceBuffer
- ENDIF
-
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ; interface for Audio Components
- ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ;Volume is described as a value between 0 and 1, with 0 indicating minimum
- ; volume and 1 indicating maximum volume; if the device doesn't support
- ; software control of volume, then a value of unimpErr is returned, indicating
- ; that these functions are not supported by the device
- IF GENERATING68K THEN
- Macro
- _AudioGetVolume
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioGetVolume
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _AudioSetVolume
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioSetVolume
- ENDIF
-
- ;If the device doesn't support software control of mute, then a value of unimpErr is
- ;returned, indicating that these functions are not supported by the device
- IF GENERATING68K THEN
- Macro
- _AudioGetMute
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioGetMute
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _AudioSetMute
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioSetMute
- ENDIF
-
- ;AudioSetToDefaults causes the associated device to reset its volume and mute values
- ;(and perhaps other characteristics, e.g. attenuation) to "factory default" settings
- IF GENERATING68K THEN
- Macro
- _AudioSetToDefaults
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioSetToDefaults
- ENDIF
-
- ;This routine is required; it must be implemented by all audio components
- IF GENERATING68K THEN
- Macro
- _AudioGetInfo
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioGetInfo
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _AudioGetBass
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioGetBass
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _AudioSetBass
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioSetBass
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _AudioGetTreble
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioGetTreble
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _AudioSetTreble
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioSetTreble
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _AudioGetOutputDevice
- dc.w $2F3C
- dc.w $0000
- dc.w $0000
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioGetOutputDevice
- ENDIF
-
- ;This is routine is private to the AudioVision component. It enables the watching of the mute key.
- IF GENERATING68K THEN
- Macro
- _AudioMuteOnEvent
- dc.w $2F3C
- dc.w $0000
- dc.w $0029
- moveq #0,d0
- dc.w $A82A
- EndM
- ELSE
- IMPORT AudioMuteOnEvent
- ENDIF
-
- ENDIF ; __SOUNDCOMPONENTS__
-